home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Softshoe / Lisa's Mac Parts / Windows / WindowObject.h < prev    next >
Text File  |  2000-06-23  |  5KB  |  143 lines

  1. // WindowObject.h
  2.  
  3. #ifndef WindowObject_h
  4. #define WindowObject_h
  5.  
  6. #ifndef __WINDOWS__
  7. #include <Windows.h>
  8. #endif
  9. #ifndef ConstPString_h
  10. #include "ConstPString.h"
  11. #endif
  12. #ifndef Str_h
  13. #include "Str.h"
  14. #endif
  15. #ifndef PointObject_h
  16. #include "PointObject.h"
  17. #endif
  18. #ifndef Rectangle_h
  19. #include "Rectangle.h"
  20. #endif
  21. #ifndef GrafPortObject_h
  22. #include "GrafPortObject.h"
  23. #endif
  24.  
  25. class RegionObject;
  26.  
  27. class WindowObject: public WindowRecord
  28.   {
  29.     private:
  30.         // not implemented:
  31.             WindowObject( const WindowObject& );
  32.             void operator=( const WindowObject& );
  33.  
  34.         WStateData& StateData();
  35.         const WStateData& StateData() const;
  36.     
  37.         static WindowObject *DoCheckedCast( const void * );
  38.         
  39.     public:
  40.         enum Definition
  41.           {
  42.             noZoom                = documentProc,
  43.             dialog                = dBoxProc,
  44.             plain                    = plainDBox,
  45.             shadowed                = altDBoxProc,
  46.             noGrowNoZoom        = noGrowDocProc,
  47.             movableModal        = movableDBoxProc,
  48.             document                = zoomDocProc,
  49.             noGrow                = zoomNoGrow,
  50.             rounded                = rDocProc
  51.           };
  52.         
  53.         WindowObject( Definition = document, bool withCloseBox = true );
  54.         
  55.         ~WindowObject()                                        { CloseWindow( &port ); }
  56.         
  57.         void Select()                                            { SelectWindow( &port ); }
  58.         void SendBehind( WindowObject& w )                { ::SendBehind( &port, &w.port ); }
  59.         void SendToBack()                                        { ::SendBehind( &port, 0 ); }
  60.         
  61.         uint32 Index() const;
  62.         void SetIndex( uint32 );
  63.         
  64.         void Show()                                                { ShowWindow( &port ); }
  65.         void Hide()                                                { HideWindow( &port ); }
  66.         
  67.         void SetTitle( ConstPString s )                    { SetWTitle( &port, s ); }
  68.         void GetTitle( String255& s ) const             { GetWTitle( const_cast<WindowPtr>(&port), s ); }
  69.         
  70.         PointObject Position() const                        { return Port().GlobalBounds().TopLeft(); }
  71.         void SetPosition( PointObject p )                { MoveWindow( &port, p.h, p.v, false ); }
  72.         void MoveByDragging( PointObject mouse )        { DragWindow( &port, mouse, &Rectangle::big ); }
  73.         
  74.         PointObject Size() const                            { return Port().LocalBounds().Size(); }
  75.         void SetSize( PointObject size )                    { SizeWindow( &port, size.h, size.v, true ); }
  76.         PointObject SizeByDragging( PointObject mouse,
  77.                                              PointObject minimum,
  78.                                              PointObject maximum );
  79.         
  80.         Rectangle GlobalBounds() const                    { return Port().GlobalBounds(); }
  81.         void SetBounds( Rectangle );
  82.         
  83.         Rectangle UserBounds() const                        { return StateData().userState; }
  84.         void SetUserBounds( Rectangle r )                { StateData().userState = r; }
  85.         
  86.         Rectangle StandardBounds() const                    { return StateData().stdState; }
  87.         void SetStandardBounds( Rectangle r )            { StateData().stdState = r; }
  88.         
  89.         bool TrackZoomInBox( PointObject mouse )        { return TrackBox( &port, mouse, inZoomIn ); }
  90.         bool TrackZoomOutBox( PointObject mouse )        { return TrackBox( &port, mouse, inZoomOut ); }
  91.         bool TrackCloseBox( PointObject mouse )        { return TrackGoAway( &port, mouse ); }
  92.         
  93.         void ZoomToUserBounds();
  94.         void ZoomToStandardBounds();
  95.         
  96.         Rectangle LocalBounds() const                        { return Port().LocalBounds(); }
  97.         
  98.         int32 RefCon() const                                    { return GetWRefCon( const_cast<WindowPtr>( &port ) ); }
  99.         void SetRefCon( int32 r )                            { SetWRefCon( &port, r ); }
  100.  
  101.         static WindowObject *Front()                        { return reinterpret_cast<WindowObject *>( FrontWindow() ); };
  102.         WindowObject *Next()                                    { return static_cast<WindowObject *>( nextWindow ); }
  103.         
  104.         bool IsFrontmost() const                            { return this == Front(); }
  105.         
  106.         GrafPortObject& Port()                                { return static_cast<GrafPortObject&>( port ); }
  107.         const GrafPortObject& Port() const                { return static_cast<const GrafPortObject&>( port ); }
  108.         
  109.         int16 Kind() const                                    { return windowKind; }
  110.         bool Visible() const                                    { return visible != 0; }
  111.         bool Highlighted() const                            { return hilited != 0; }
  112.         bool HasCloseBox() const                            { return goAwayFlag != 0; }
  113.         bool HasZoomBox() const                                { return spareFlag != 0; }
  114.         
  115.         // These are in global coordinates:
  116.             const RegionObject& StructureRegion() const    { return *reinterpret_cast<const RegionObject*>( &strucRgn ); }
  117.             const RegionObject& ContentRegion() const        { return *reinterpret_cast<const RegionObject*>( &contRgn ); }
  118.             const RegionObject& InvalidRegion() const        { return *reinterpret_cast<const RegionObject*>( &updateRgn ); }
  119.         
  120.         // This is in local coordinates:
  121.             const RegionObject& VisibleRegion() const        { return *reinterpret_cast<const RegionObject*>( &port.visRgn ); }
  122.         
  123.         int16 TitleWidth() const                            { return titleWidth; }
  124.         
  125.         ControlHandle FirstControl() const                { return reinterpret_cast<ControlHandle>(controlList); }
  126.         
  127.         void SetVisibility( bool visible )                { ShowHide( &port, visible ); }
  128.         void SetHighlighting( bool highlighted )        { HiliteWindow( &port, highlighted ); }
  129.         
  130.         GDHandle NearestScreen() const;
  131.         GDHandle DeepestScreen() const;
  132.         
  133.         static uint32 CountVisibleWindows();
  134.         static uint32 CountVisibleWindows( Rectangle );
  135.         
  136.         Rectangle FrameSize() const;
  137.         
  138.         static WindowObject *CheckedCast( void *p )                    { return DoCheckedCast(p); }
  139.         static const WindowObject *CheckedCast( const void *p )    { return DoCheckedCast(p); }
  140.   };
  141.  
  142. #endif
  143.